package cn.ljy.mes.web.controller.backstage.shop;


import cn.ljy.authority.web.controller.backstage.BaseBackstageController;
import cn.ljy.common.annotation.LimitRequest;
import cn.ljy.common.model.result.ResponseData;
import cn.ljy.mes.model.ShopCustomer;
import cn.ljy.mes.model.query.ShopCustomerQuery;
import cn.ljy.mes.service.ShopCustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "后台商城客户管理模块")
@RestController
@RequestMapping(value = "/backstage/shop/customer")
public class ShopCustomerController extends BaseBackstageController<ShopCustomer, ShopCustomerQuery,String> {

    @Autowired
    private ShopCustomerService baseService;

    @Override
    protected String getAuthorityPrefix() {
        return "shop:customer"; // 定义模块权限前缀
    }


    //================================定制查询=================================

//    @PreAuthorize("hasAuthority('shop:customer:query')")
    @ApiOperation(value = "根据账户名查询信息，与普通查询不同，这里是按账户名查询结果的匹配度来进行专门的排序")
    @LimitRequest
    @GetMapping("/username")
    protected ResponseData queryUserName(String username){
        return ResponseData.success(baseService.queryByUserNameWithExactMatchFirst(username));
    }

}
